package teams

import (
	"itodo/core/dao/table"
	"itodo/core/dao/teamdao"
	"itodo/core/localwrap"
)

var logTasks = localwrap.GetLogger().Fork("itodo/core/service/teams", "Tasks")

type Tasks struct{}

func (s Tasks) Query(param teamdao.TasksQueryParam) ([]table.Task, int64) {
	logTasks.Debug().Func("Query").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Tasks{RedisedMysql: d}.Query(param)
}

func (s Tasks) Get(id int) table.Task {
	logTasks.Debug().Func("Get").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Tasks{RedisedMysql: d}.Get(id)
}

func (s Tasks) Add(param teamdao.TasksAddParam) table.Task {
	logTasks.Debug().Func("Add").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Tasks{RedisedMysql: d}.Add(param)
}

func (s Tasks) Update(param teamdao.TasksUpdateParam) {
	logTasks.Debug().Func("Update").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	teamdao.Tasks{RedisedMysql: d}.Update(param)
}

func (s Tasks) Delete(id int) {
	logTasks.Debug().Func("Delete").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	teamdao.Tasks{RedisedMysql: d}.Delete(id)
}
